package com.zjj.bams.server;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date
 */
public class ATMServer extends JFrame {

    ServerPanel serverPanel;
    RankPanel rankPanel;

    public ATMServer(){
        //设置服务端窗体的基本信息
        this.setTitle("ATM 服务器");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(500 , 550);
        this.setLocationRelativeTo(null);

        //卡片式布局
        Container container = this.getContentPane();
        container.setLayout(new CardLayout());
        serverPanel = new ServerPanel();
        rankPanel = new RankPanel();
        //第一个展示的页面 serverPanel
        container.add(serverPanel , "server");
        container.add(rankPanel , "rank");

        //关闭服务端 - 添加窗口关闭的事件
        this.addWindowListener(new WindowAdapter(){
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }

    public static void main(String[] args) {
        new ATMServer().setVisible(true);
    }

}
